package com.util;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;

/**
 * @BelongsPackage: com.hq1.javaweb.util
 * @Author: jiangjunjie
 * @CreateTime: 2025-02-17  23:46
 * @Description: TODO
 * @Version: 1.8
 */
public class BaseDao {
    public static SqlSessionFactory build=null;
    static {
        try {
            InputStream resourceAsStream = Resources.getResourceAsStream("mybatis-config.xml");
            build = new SqlSessionFactoryBuilder().build(resourceAsStream);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }

    }
    //通用查询
    public static SqlSession baseSelect(){
        SqlSession sqlSession = build.openSession(true);
        return sqlSession;
    }


}
